<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>基本表达式对象</title>
</head>
<body>
<h1>从session中获取值</h1>
<span th:text="${#session.getAttribute('data')}"></span><br/>
<span th:text="${#httpSession.getAttribute('data')}"></span><br/>
<span th:text="${session.data}"></span><br/>

<script type="text/javascript" th:inline="javascript">
    //http://localhost:8080/springboot/user/detail
    //获取协议名称
    var scheme = [[${#request.getScheme()}]];
    //获取服务器名称
    var severName = [[${#request.getServerName()}]];
    //获取服务器端口号
    var serverPort = [[${#request.getServerPort()}]];
    //获取上下文根
    var contextPath =[[${#request.ContextPath()}]];
    //获取全路径
    var allPath = scheme + "://" +serverPort + ":" + contextPath;

    var requestURL = [[${#httpServletRequest.requestURL}]];
    var queryString = [[${#httpServletRequest.queryString}]];
    var requestAddress = requestURL + "?" + queryString;
    alert("requestURL=="+requestURL)
    alert("queryString=="+queryString)
    alert(requestAddress);
</script>
</body>
</html>